<?php


namespace App\Log;


use Auth,Saas;

class AdminSettingLog extends AdminLog
{
    protected $pre = [];    //修改前
    protected $next = [];   //修改后
    protected $module;      //操作模块

    protected $mean = [
        'name' => '字段名称',
        'remark' => '备注',
        'value' => '值',
    ];


    public function __construct($pre,$next,$module)
    {
        $this->pre = $pre;
        $this->next = $next;
        $this->module = $module;
    }

    public function addLog()
    {
        $this->data = $this->combinedData();
        parent::addLog();
    }


    public function combinedData():array
    {
        $content = [];
        $data = [
            'module' =>  $this->module->pid,
            'operate' =>  $this->module->id,
            'type' =>  $this->module->type,
            'main' =>  isset($this->pre['remark']) ? $this->pre['remark'] : $this->next['remark'],
            'main_id' => 0,
            'content' => json_encode($this->next),
            'user_id' => auth('admin')->user()->id,
            'ip'    => get_proxy_ip(),
            'model' => $this->module->model,
        ];

        return $data;
    }
}
